<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>


    <style>
        div {
            width: 100px;
            height: 100px;
            background-color: skyblue;
        }

        .change {
            background-color: purple;
            color: #fff;
            font-size: 30px;
            margin-top: 100;
        }
    </style>
</head>

<body>
    <div class="first">文本</div>


    <script>
        //1.获取修改元素行内样式
        let div = document.querySelector('div');
        div.onclock = function () {
            // div.style.color = '#fff';
            // div.style.fontSize = '30px';
            // div.style.marginTop = '100px';
            // div.style.backgroungColor = 'purple'

            //2.通过类名修改样式
            div.className = 'first change'
        }
    </script>
</body>

</html>